/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#include <pch.h>
#include <baja/transition_tracking/transition_tracking_helpers.h>
#include <baja/assert.hpp>

namespace baja { namespace transition_tracking {

// TRACK: bug 479 : need to use console tracing.
#define DEBUG_CONSOLE_TRACE(x)
#define DEBUG_CONSOLE_TRACE_F(X)

#ifndef DEBUG_CONSOLE_TRACE
#define DEBUG_CONSOLE_TRACE(x) OutputDebugString(x)
#define DEBUG_CONSOLE_TRACE_F(x) OutputDebugString((x).str().c_str())
#endif

generic_transition_parameters::generic_transition_parameters(
    // const generic_transition_type& transitionType,
    const b::uint32& transitionType,
    const b::uint32& objectType,
    const b::uint32& objectId) :
    _transitionType(transitionType),
    _objectType(objectType),
    _objectId(objectId),
    _objectOrder(0)
{
}

void generic_transition_parameters::dump()
{
    DEBUG_CONSOLE_TRACE_F(
        boost::wformat(L"UNDO-DATA : page_model_create_transition : transition type = %i : child type = %i : child id = %i : child number = %i") %
        _transitionType %
        _objectType %
        _objectId %
        _objectOrder
        );
}

b::uint32 generic_transition_parameters::transitionType(void)
{
    return _transitionType;
}

transition_context::transition_context(const std::shared_ptr<itransition_tracking_service>& trackingService)
{
    _trackingService = trackingService;
    _trackingService->startTransitionBundle();
}

transition_context::~transition_context()
{
    _trackingService->endTransitionBundle();
}

}} // journal::transition_tracking